package com.csrcb.constant;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Properties;

/**
 * @Classname FileParamValue
 * @Description 读取文件中的属性值
 * @Date 2020/12/15 14:54
 * @Created by gangye
 */
public final class FileParamValue {
    private static Logger log = LoggerFactory.getLogger(FileParamValue.class);
    private static String appid;

    private static String secret;

    private static String touser;

    static {
        Properties prop = new Properties();
        try {
            //configConstant.properties配置文件
            InputStream is = FileParamValue.class.getClassLoader().getResourceAsStream("configConstant.properties");
            // 传入编码格式解决中文乱码
            prop.load(new InputStreamReader(is,"utf-8"));
            appid = prop.getProperty("appid");
            secret = prop.getProperty("secret");
            touser = prop.getProperty("towechatid");
        } catch (IOException e) {
            log.error("读取配置文件获取信息异常");
        }
    }

    private FileParamValue(){}

    public static String getAppid() {
        return appid;
    }

    public static String getSecret() {
        return secret;
    }

    public static String getTouser() {
        return touser;
    }
}
